import {bannersAdd,bannersList,bannersOne,bannersUpdate,bannersDel} from "../../request/api"
import { successAlert } from "../../utils/alert"
const state={
    banners:[]
}
const mutations={
    changeBanners(state,res){
        state.banners=res;
    }
}
const actions={
    bannersActions(context){
        console.log("jaja");
        bannersList().then(res=>{
            if(res.code===200){
                console.log(res);
                context.commit("changeBanners",res.list)
            }
        })
    },
    bannersUpdateActions(context,data){
        bannersUpdate(data).then(res=>{
            if(res.code===200){
                successAlert("修改成功")
            }
        })
    }
}
const getters={
    banners(state){
        return state.banners;
    }
}

export default {
    state,
    mutations,
    actions,
    getters,
    namespaced:true
}